import {Component} from 'react';
import {NavLink} from 'react-router-dom';
import axios from 'axios';
class Home extends Component{
    state = {
        list:[]
    }
    render(){
        let {list} = this.state;
        return(
            <div>
                <h1>首页</h1>
                <ol>
                    {
                        list.map(item=>{
                            return <li key={item.id}>
                                 <img src={item.image} alt="" style={{width:"100px"}}/>
                                 <NavLink to={`/info/${item.id}/${item.price}`}>{item.storeName}</NavLink>
                            </li>
                        })
                    }
                </ol>
            </div>
        )
    }
   async componentDidMount(){
        // 获取商品列表
       let res = await axios.get("https://apif.java.crmeb.net/api/front/index/product/1/?page=1&limit=10");
       console.log(res)
       this.setState({
        list:res.data.data.list
       })
    }
}
export default Home;